//
//  NIMAvatarImageVi.m
//  meiyinxiang
//
//  Created by 陈李飞 on 2017/11/2.
//  Copyright © 2017年 hbjApple. All rights reserved.
//

#import "NIMAvatarImageVi.h"
#import "UIView+NIM.h"
#import "objc/runtime.h"
#import "NIMKitDependency.h"
#import "NIMKit.h"
#import "NIMKitInfoFetchOption.h"


@implementation NIMAvatarImageVi



- (void)setAvatarByMessage:(NIMMessage *)message
{
    NIMKitInfoFetchOption *option = [[NIMKitInfoFetchOption alloc] init];
    option.message = message;
    NSString *from = nil;
    if (message.messageType == NIMMessageTypeRobot)
    {
        NIMRobotObject *object = (NIMRobotObject *)message.messageObject;
        if (object.isFromRobot)
        {
            from = object.robotId;
        }
    }
    if (!from)
    {
        from = message.from;
    }
    NIMKitInfo *info = [[NIMKit sharedKit] infoByUser:from option:option];
    NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:info.infoId];
   // NSURL *url = user.userInfo.avatarUrl ? [NSURL URLWithString:user.userInfo.avatarUrl] : nil;

    [self nim_setImageWithURL:[NSURL URLWithString:user.userInfo.avatarUrl]  placeholderImage:info.avatarImage];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
